<!DOCTYPE html>
<html lang="en">
  <head>
    <meta name="viewport" content="width=device-width" />
    <title>Media Chrome Standalone Controls Example</title>
    <script type="module" src="../../dist/index.js"></script>
    <style>
      /** add styles to prevent CLS (Cumulative Layout Shift) */
      media-controller:not([audio]) {
        display: block;         /* expands the container if preload=none */
        max-width: 640px;       /* allows the container to shrink if small */
        aspect-ratio: 16 / 9;   /* set container aspect ratio if preload=none */
      }

      video {
        width: 100%;      /* prevents video to expand beyond its container */
      }

      media-loading-indicator {
        --media-loading-indicator-opacity: 1;
      }

      .examples {
        margin-top: 20px;
      }
    </style>
  </head>
  <body>
    <main>
      <h1>Standalone Controls Example</h1>
      <p>
        This example shows how individual controls can be used without the
        <code>media-controller</code> element.
      </p>

      <media-controller id="controller">
        <video
          playsinline
          slot="media"
          src="https://stream.mux.com/DS00Spx1CV902MCtPj5WknGlR102V5HFkDe/high.mp4"
        >
          <track
            label="English"
            kind="captions"
            srclang="en"
            default
            src="./vtt/en-cc.vtt"
          />
        </video>
      </media-controller>

      <h2>Outside the control-bar element</h2>
      <media-play-button mediacontroller="controller"></media-play-button>
      <media-live-button mediacontroller="controller"></media-live-button>
      <media-mute-button mediacontroller="controller"></media-mute-button>
      <media-seek-backward-button mediacontroller="controller"></media-seek-backward-button>
      <media-seek-forward-button mediacontroller="controller"></media-seek-forward-button>
      <media-volume-range mediacontroller="controller"></media-volume-range>
      <media-time-range mediacontroller="controller"></media-time-range>
      <!-- It works for "display-only" components, too! -->
      <media-time-display
        mediacontroller="controller"
        remaining
        showduration
      ></media-time-display>
      <media-captions-button mediacontroller="controller"></media-captions-button>
      <media-playback-rate-button mediacontroller="controller"></media-playback-rate-button>
      <media-pip-button mediacontroller="controller"></media-pip-button>
      <media-airplay-button mediacontroller="controller"></media-airplay-button>
      <media-cast-button mediacontroller="controller"></media-cast-button>
      <media-fullscreen-button mediacontroller="controller"></media-fullscreen-button>
      <media-loading-indicator mediacontroller="controller"></media-loading-indicator>

      <h2>Inside the control-bar element</h2>
      <p>
        Note: You only need to set the <code>mediacontroller=</code> attribute
        on the <code>media-control-bar</code>. The media-controller will pass
        the media state details to their child media-chrome elements
        automatically.
      </p>

      <media-control-bar mediacontroller="controller">
        <media-play-button></media-play-button>
        <media-live-button></media-live-button>
        <media-mute-button></media-mute-button>
        <media-seek-backward-button></media-seek-backward-button>
        <media-seek-forward-button></media-seek-forward-button>
        <media-volume-range></media-volume-range>
        <media-time-range></media-time-range>
        <media-time-display remaining showduration></media-time-display>
        <media-captions-button></media-captions-button>
        <media-playback-rate-button></media-playback-rate-button>
        <media-pip-button></media-pip-button>
        <media-airplay-button></media-airplay-button>
        <media-cast-button></media-cast-button>
        <media-fullscreen-button></media-fullscreen-button>
        <media-loading-indicator></media-loading-indicator>
      </media-control-bar>

      <div class="examples">
        <a href="./">View more examples</a>
      </div>
    </main>
  </body>
</html>
